package Static;

public class Person {
    String name;
    int age;

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    //代码块都在构造方法之前调用
    static {//静态代码块最先调用但是只执行一次
        //静态代码块一般用来赋初值
        System.out.println("静态代码块");
    }
    {
        //匿名代码块紧接着静态代码块
        System.out.println("匿名代码块");
    }
    public Person() {//然后才是构造方法
        System.out.println("构造方法");
    }
    public static void main(String[] args) {
        Person p = new Person();
        Person p1 = new Person();
        Person p2 = new Person();
    }
}
